const express = require('express');
const bodyParser = require('body-parser');

const server = express();

server.use(bodyParser.urlencoded({ extended: false }));
server.use(bodyParser.json());

// 导入分析模块
const { toSatrt } = require('./getGameData');

server.use(async (req, res, next) => {
  // 允许所有请求
  res.header('Access-Control-Allow-Origin', '*');
  res.header(
    'Access-Control-Allow-Headers',
    'Origin',
    'X-Requested-With',
    'Content-Type',
    'Accept',
    'Authorization'
  );
  next();
});

server.use('/getSortGameList', (req, res) => {
  const { start, end } = req.body;
  toSatrt(start, end, 1, 1, res);
});
server.use('/test', (req, res) => {
  console.log('ceshi');
  let temp = require('./test.json');
  res.end(JSON.stringify(temp));
});

server.listen(11112);
